﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage2.master" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient"  %>
<script runat="server">
    
    protected void Page_Load()
    {

        string conStr = @"Data Source=ADMIN-PC\SQLEXPRESS;Initial Catalog=graduate_manage;Integrated Security=True";  
      
      SqlConnection connection = new SqlConnection(conStr);
      SqlCommand cmd = connection.CreateCommand();
      connection.Open();

      cmd.CommandText = " SELECT  COUNT(*)  FROM INFO_GRADUATE";
      SqlDataReader reader = cmd.ExecuteReader();

      reader.Read();
      
      int countEmploy = reader.GetInt32(0); 
      connection.Close();//否则下一步不能重新读

      connection.Open();

      string year= "2011";
     //string year = Session["selelctyear"].ToString();
      cmd.CommandText = "SELECT GRA_MOVE,COUNT(*) AS COUNT_MOVE_EMPLOY " +
      "  FROM INFO_GRADUATE" +
      " WHERE GRA_GRATIME=" + "'" + year + "-06-07'" +
       "GROUP BY GRA_MOVE ";
       

     
      reader = cmd.ExecuteReader();
      int [] perc = new int[countEmploy];
      int[] countY = new int[countEmploy];
      string [] moveX = new string[countEmploy];
      int i=0;
      while (reader.Read())
      {
          moveX[i] = reader.GetString(0);
          perc[i] = (reader.GetInt32(1) *100)/ countEmploy;
          countY[i] = reader.GetInt32(1); 
          i++;   
      }
      int move_count = i;
      connection.Close();

      Series series = new Series("series1");
      series.ChartType = SeriesChartType.Doughnut;
      int j =0;
      for( ; j<i;j++)
      {
          
          series.Points.AddY(countY[j]);
          series.Points[j].AxisLabel = moveX[j];
          series.Points[j].Label = moveX[j] + '(' + perc[j].ToString() + "%" + ')';
          series.Points[j].ToolTip = countY[j].ToString();
      }
      series.YAxisType = AxisType.Primary;
      series.YValueType = ChartValueType.Int32;
      Chart1.Series.Add(series);
    }
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">

    <asp:Chart ID="Chart1" runat="server" Height="350px" Width="500px"
       Palette="Pastel"
       >
        <Series>
            
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1" BackGradientStyle="DiagonalRight" 
                BackImageTransparentColor="Cyan" BorderColor="Transparent" BorderWidth="0" 
                BackSecondaryColor="Transparent">
            </asp:ChartArea>
            
                    
        </ChartAreas>
        
        <Titles>
            <asp:Title  Font="隶书, 12pt" ForeColor="Black" Name="Title1" 
                Text="户口迁移地环状图">
            </asp:Title>
        </Titles>

<BorderSkin SkinStyle="Emboss"></BorderSkin>
    </asp:Chart>


</asp:Content>



